package com.seeyon.ctp.portal.sso;

import com.alibaba.fastjson.JSONObject;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.util.Strings;

import java.util.Base64;

public class MyjsxySSOLoginHandshake
        extends SSOLoginHandshakeAbstract
{
    private static final Logger logger = Logger.getLogger(MyjsxySSOLoginHandshake.class);

    private String ticketName = "ticket";

    @Override
    public String handshake(String token)
    {
        String jsonStr = "";
        JSONObject jsonObject = new JSONObject();
        String memberLoginName = null;
        try
        {
            if (Strings.isNotBlank(token))
            {
                jsonStr = new String(Base64.getDecoder().decode(token), "UTF-8");
                jsonObject = JSONObject.parseObject(jsonStr);
            }
        }
        catch (Exception e)
        {
            logger.error("HT--单点登录异常：", e);
        }
        return String.valueOf(jsonObject.get("loginName"));
    }

    @Override
    public void logoutNotify(String arg0) {}
}
